package com.cx.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cx.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {

    @Select("select  * from t_employee where emp_dep_no = #{depNo}")
    List<Employee> empsByDepNo(String depNo);

    List<Employee> getEmpListAndDept();
    List<Employee> getEmpListAndDept1();
    List<Employee> getEmpListAndDept2();
    @Select("select * from t_employee")
    @Results({
            @Result(property = "empDepNo", column = "emp_dep_no"),
            @Result(property = "department", column = "emp_dep_no",
                    one = @One(select = "com.cx.mapper.DepartmentMapper.getDept"))
    })
    List<Employee> getEmpListAndDept3();

    @Select("select * from t_employee ${ew.customSqlSegment}")
    @Results({
            @Result(property = "empDepNo", column = "emp_dep_no"),
            @Result(property = "department", column = "emp_dep_no",
                    one = @One(select = "com.cx.mapper.DepartmentMapper.getDept"))
    })
    IPage<Employee> getEmpListAndDeptPageConditions(IPage page,@Param(Constants.WRAPPER) Wrapper wrapper);
}
